﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using NHibernate;
using NHibernate.Event.Default;

namespace NHibernateTests.Tests
{

    public class UpdateTimeListener : DefaultSaveOrUpdateEventListener
    {
        protected override object PerformSaveOrUpdate(NHibernate.Event.SaveOrUpdateEvent evt)
        {            
            if (evt.Entity is IAuditable)
            {
                (evt.Entity as IAuditable).UpdateDate = DateTime.Now;
            }
            return base.PerformSaveOrUpdate(evt);
        }        
    }

    interface IAuditable
    {
        DateTime UpdateDate { get; set; }
    }
    public class Ninja : IAuditable
    {
        public int ID { get; set; }
        public string Name { get; set; }
        public DateTime UpdateDate { get; set; }
    }
}
